import os
import unittest

import nose

from limber import componentfinder
from limber import abilities
from mocks import *
from tests import tools

def setup_module():
    set_mockdir(1)


class TestComponentFinder2(unittest.TestCase):
    
    def setUp(self):
        self.parent = MockApplication()
        userdir = self.parent.userdir_path()
        systemdir = self.parent.systemdir_path()
        self.finder = componentfinder.ComponentFinder(userdir, systemdir)

    @tools.with_path(get_systemdir)
    @tools.with_path(get_userdir)
    def testFindComponentsInfos(self):
        usrdir, sysdir = self.finder.get_paths()
        
        right_infos = [
            mock_component_infos(0)[0].__dict__,
            mock_component_infos(1)[0].__dict__, 
            mock_component_infos(2)[0].__dict__
            ]
        
        usrinfos = list(self.finder.find_components_infos(usrdir))
        sysinfos = list(self.finder.find_components_infos(sysdir))
        
        got_infos = [
            usrinfos[0].__dict__, 
            sysinfos[0].__dict__,
            sysinfos[1].__dict__, 
            ]
        
        self.assertEqual(got_infos, right_infos)
